package com.teach.food.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.mongodb.util.JSON;
import com.teach.dto.LoginUser;
import com.teach.food.commons.GetShopsInfo;
import com.teach.food.service.FoodOrderInfoService;
import com.teach.mapper.FoodOrderInfoMapper;
import com.teach.mapper.FoodOrderMapper;

import lombok.extern.slf4j.Slf4j;


/**
 * <pre>
 * 订单报表
 * Author : G_peng
 * Date : 2019年12月14日
 * Version : 0.0.1
 * Copyright 2019 Gpeng.top Inc. All rights reserved. 
 * </pre>
 */
@Slf4j
@Controller
@RequestMapping("/food/statement")
public class StatementController {
	@Autowired
	private FoodOrderInfoService service;
	@Autowired
	private GetShopsInfo info;
	
	@RequestMapping(value = "/week.do", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public Object doWeek(Model model,@RequestParam(value = "str",defaultValue = " ")String str,LoginUser user) {
		log.debug("{}","week"+service.selectWeek(str,info.getShopName(user)));
		return service.selectWeek(str,info.getShopName(user));
	}
	
	@RequestMapping(value = "/month.do", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public Object doMonth(Model model,@RequestParam(value = "str",defaultValue = " ")String str,LoginUser user) {
		log.debug("{}",service.selectMonth(str,info.getShopName(user)));
		return service.selectMonth(str,info.getShopName(user));
	}
	
	@RequestMapping(value = "/lastmonth.do", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public Object doLastMonth(Model model,LoginUser user) {
		log.debug("{}","month"+service.selectLastMonth(info.getShopName(user)));
		return service.selectLastMonth(info.getShopName(user));
	}
	
}
